package com.sxz.sbs.module.client.presenter;

import com.sxz.sbs.app.App;
import com.sxz.sbs.module.client.bean.CarListBean;
import com.sxz.sbs.module.client.view.CarListView;
import com.sxz.sbs.rx.RxPresenter;
import com.sxz.sbs.rx.RxSubscriber;
import com.sxz.sbs.rx.RxUtil;

import java.util.HashMap;
import java.util.List;

/**
 * 获取客户车辆列表
 * @author hp
 */
public class CarListPresenter extends RxPresenter<CarListView>{
    /**
     * @param map
     */
    public void getCarList (final HashMap<String,Object> map) {
        addSubscribe(App.getInstance().getApi().getCarList(map)
                .compose(RxUtil.<List<CarListBean>>handleResult())
                .subscribeWith(new RxSubscriber<List<CarListBean>>(mView){
                    @Override
                    public void onNext(List<CarListBean> data) {
                       mView.onCarListSuccess(data);
                    }
                })
        );
    }
    public void deleteCarList (final HashMap<String,Object> map) {
        addSubscribe(App.getInstance().getApi().deleteCarList(map)
                .compose(RxUtil.<String>handleResult())
                .subscribeWith(new RxSubscriber<String>(mView,true){
                    @Override
                    public void onNext(String data) {
                        mView.onDeleteCarSuccess();
                    }
                })
        );
    }
}
